package com.clstu.method;

public class ThreadMethod03 {
    public static void main(String[] args) throws InterruptedException {
        MyDaemonThreat myDaemonThreat = new MyDaemonThreat();
        myDaemonThreat.setDaemon(true);//将子线程设置为守护线程，则主线程结束后子线程即使
                                  //使无限循环也会自动结束
        myDaemonThreat.start();
        for (int i = 0; i < 10; i++) {
            System.out.println("宝强正在幸苦的工作。。。");
            Thread.sleep(200);
        }
    }
}
class MyDaemonThreat extends Thread{
    @Override
    public void run() {
        while (true) {
            System.out.println("马蓉和宋吉快乐聊天，哈哈哈哈。。。");
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}